/***************************************************************************
 *   Copyright (C) 2004 by cyril dupuit                                    *
 *   cyrildupuit@hotmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

//*****************************************************************************
// Nom du module : idt.h
// Description : Gestion des vecteurs d'interruptions
//*****************************************************************************
 
// Historique :
// 28/10/04 : Creation du module V1.0  

#ifndef IDT_HEADER
#define IDT_HEADER

//*****************************************************************************
// Definition des equivalences :
//*****************************************************************************
#define	CS_SELECTOR		0x08

#define INTGATE 0x8E00  /* utilise pour gerer les interruptions */
#define TRAPGATE 0x8F00 /* utilise pour faire des appels systemes */
#define TASKGATE 0x8500 /* utilise pour commuter des taches */


struct IdtGate {
	unsigned short int Offset0_15;	
	unsigned short int Selector;
	unsigned char Reserved:5;   /* 4..0 */
	unsigned char Flags:3;      /* 7..5 */
	unsigned char Type:3;       /* 10..8 (interrupt gate, trap gate...) */
	unsigned char OpSize:1;    /* 11 (0=16bits instructions, 1=32bits instr.) */
	unsigned char Zero:1;       /* 12 */
	unsigned char Dpl:2;        /* 14..13 */
	unsigned char Present:1;    /* 15 */
	unsigned short int Offset16_31;	
}__attribute__ ((packed));

/* registre IDTR */
struct Idtr {
	unsigned short int Limit;
	unsigned long Base;
}__attribute__ ((packed, aligned (8)));

//*****************************************************************************
// But de la procedure : Initialiser l'IDT
// Entree : Aucune
// Sortie : Aucune
//*****************************************************************************
void InitIdt(void);

//*****************************************************************************
// But de la fonction : Installer un vecteur d'interruption
// Entrees :
//	IntNo : Numero du vecteur d'interruption
//	pProc : Adresse de la procedure a eAsmDefaultIntProcxecuter
// Sortie : Aucune
//*****************************************************************************
Status_t SetIntVector(int IntNo, void * pProc);

//*****************************************************************************
// But de la fonction : Recuperer la procedure d'interruption associe a un
// vecteur
// Entree : 
//	IntNo : Numero du vecteur d'interruption
// Parametre retourne : Pointeur sur la procedure d'interruption, NULL si
// absente
//*****************************************************************************
Status_t GetIntVector(int IntNo, void * * pProc);

//*****************************************************************************

#endif
